<template>
  <Button 
    class="tbk-item"
    type="primary" 
    :disabled="isSave"
    @click="saveItem">
    {{message}}
  </Button>
</template>
<script>
export default {
  name: 'TbkItem',

  mixins: [],

  components: {},

  props: {
    itemInfo:{
      type:Object,
      required: true
    },    
  },

  data() {
    return {
      isSave:false,
      message:"保存",
    };
  },

  computed: {},

  watch: {
    'itemInfo.num_iid':function(){
      this.isSave=false;
    }
  },

  created() {

  },

  mounted() {
    
  },

  destroyed() {},

  methods: {
    saveItem(){
      this.message="上传中";
      this.isSave=true;
      this.$http({
        url:"/tbk/saveitem",
        method:"post",
        data:this.itemInfo,
      })
      .then((response)=>{
        //console.log(response);
        if(response.data.num_iid==this.itemInfo.num_iid){
          this.message="已保存";          
        }else{
          this.message='保存失败';
          this.isSave=false;
        }        
      });
    }
  }
}
</script>
<style >
</style>